home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / sgwnd10 / enumwind.vbs < prev    next >
Encoding:
Text File  |  1998-08-07  |  1.3 KB  |  41 lines

  1. '--------------------------------------------------------------------------
  2. ' EnumWindows.vbs - Enumerates all open windows and prints window list
  3. '                   to the standard output (when called from CSCRIPT).
  4. '
  5. ' This file is part of the sgWindow.
  6. ' Copyright (C) 1998 Stinga
  7. ' All rights reserved.
  8. '
  9. ' This sample demonstrates usage of the sgWindow component
  10. ' and it's window enumeration capabilities.
  11. '--------------------------------------------------------------------------
  12.  
  13. option explicit
  14. dim vbCrLf
  15. vbCrLf = Chr(13) + Chr(10)
  16.  
  17. ' --- Create window object
  18. dim g, wnd, sList
  19. Set g = CreateObject("SGWindow.Globals")
  20. Set wnd = g.DesktopWindow
  21.  
  22. ' --- Collect window list
  23. sList = GetChildrenList(wnd, 0)
  24.  
  25. WScript.Echo sList
  26. WScript.Echo "This list was generated with Stinga sgWindow component." + vbCrLf + "Copyright (C) 1998 Stinga"
  27.  
  28. WScript.Quit
  29.  
  30. ' --- Recursive function to collect window list
  31. Private Function GetChildrenList(wndParent, level)
  32.     Dim wndChild, sPrefix
  33.     
  34.     sPrefix = Space(level * 2)
  35.     For Each wndChild In wndParent.Children
  36.         GetChildrenList = GetChildrenList + sPrefix + Hex(wndChild.HWND) + " - " + wndChild.Class + " - '" + wndChild.Text + "'" + vbCrLf
  37.         GetChildrenList = GetChildrenList + GetChildrenList(wndChild, level + 1)
  38.     Next
  39. End Function
  40.  
  41.